;(()=>{
    $(window).ready(()=>{
        //写函数，以及全局变量尽量封装在原型对象中减少全局变量的使用
        // let newListApplyChildren  = `<li>
			// 						<a href="javascript:;" target="_blank">
        //                                 <span class="apply_time">2019-01-13</span>
        //                                 <span class="apply_category">加州鲈鱼苗 </span>
        //                                 <span class="apply_money">0.3元/尾</span>
			// 						</a>
			// 					</li>
        // `;

        let newListPurchaseChildren = `<li>
                                    <a href="javascript:;" target="_blank">
                                        <span class="purchase_time">2019-01-14</span>
                                        <span class="purchase_category">柑桔 沙糖桔</span>
                                        <span class="purchase_area">面议</span>
                                    </a>
                               </li>
        `;
        let newListInfoChildren  = `<li>
										<a href="javascript:;" target="_blank">
											<span class="type">产地</span>
											<span class="product_name">楠竹</span>
											<span class="classify_name">竹子</span>
											<span class="info_time">01-14</span>
											<span class="info_prie">15.0/公斤</span>
											<span class="info_upDown">↑</span>
										</a>
									</li>              
        `;
        // let newListContentHotChildren = `<li class="one-third contentHot-ListChildren">
        //                                     <div class="top">
        //                                         葡萄 AA<img src="assets/images/new.png">
        //                                     </div>
        //                                     <div class="middle">苹果直销 山东苹果种植基地 脆甜</div>
        //                                     <div class="bottom">
        //                                         <button class="button button--winona button--border-thin button--round-s" data-text="直接购买">
        //                                             <span>直接购买</span>
        //                                         </button>
        //                                     </div>
        //                             </li>
        // `;


        //----------------------------------------------
        // let newProductListChildren = `<li class="one-third big_icon" style="margin: 0;">
			// 							<a href="javascript:;">
        //                                     <img src="images/lookbook1.jpg" alt="" width="119" height="129">
			// 								<div style="margin-left:20px;">梨子</div>
			// 							</a>
			// 						</li>`;
        // let newProLineAndContent = `
        //                 <div class="productLine">
			// 					<div style="position: relative;">
			// 						<div class="productList-triangle"></div>
			// 					</div>
			// 				</div>
			// 			<div class="productList-content">
			// 					<div class="productList-contentMain">
			// 						<div class="productList-contentHot">
			// 							<ul class="contentHot-List">
			// 							</ul>
			// 						</div>
			// 					</div>
			// 				</div>
        // `;

        /*---------------------------------------------------------------------------*/
        /*-----------------------函数封装-------------------------------------------*/
        /*
         循环次数动态修改
         */
        let circulateFn = (time,fatherDom,childDom)=>{
            for(let i = 0;i<time;i++){
                    $(fatherDom).append(childDom);
            }
        };
        /*---------------------------------------------------------------------------*/
        //动态添加结点

        // circulateFn(7,'.new-apply-top-ListMain-content',newListApplyChildren);

        circulateFn(7,'.new-purchase-top-ListMain-content',newListPurchaseChildren);
        circulateFn(7,'.new-info-contentMainList',newListInfoChildren);
        /*---------------------------------------------------------------------------*/
        /*动态生成productList 添加类名*/
        //class类名就是一定要添加 iconfont icon-... 图标就是first_icon second_icon third_icon 文本就是first_text

        //-------------------------------------------------------------
        // circulateFn(3,'.productListContent_secondList',newProductListChildren);

        /*动态添加类名*/
        let trendApplyClass = ()=>{
            $('.productListContent_secondList').children('li.one-third').each((index,ele)=>{
                $(ele).children('a').each((ind,el)=>{
                    $(el).children('div').each((i,e)=>{
                        if(i == 0){

                            $(e).eq(0).addClass('iconfont icon-lizi second_icon');
                            $(e).parents('a').children('div:even').addClass('iconfont icon-lizi second_icon');
                        }else{
                            $(e).parents('a').children('div:odd').addClass('second_text');
                        }
                    });
                });
            });
        };
        trendApplyClass();
        /*动态添加三角形以及下面的效果框*/

        // let trendApplyDiv = (ele)=>{
        //     $(ele).after(newProLineAndContent);
        //      // circulateFn(6,'.contentHot-List',newListContentHotChildren);
        // };
        // trendApplyDiv('.productListContent_first');

        /*---------------------------------------------------------------------------*/
        /*
          鼠标移入变色
        */
        let turnColorFn = (fatherDom,dom)=>{
            $(fatherDom).find(dom).each((index,ele)=>{
                $(ele).mouseenter(()=>{
                    $(ele).children('span').each((index,ele)=>{
                        $(ele).css({'color':"red"});
                    });
                    }).mouseleave(()=>{
                        $(ele).children('span').each((index,ele)=>{
                            $(ele).css({'color':"#666"});
                        });
                    });
                });
        };
        /*
           信息轮播效果
         */
        let [animateListIndex,animateHeight,infoTime,lastDom] = [0,$('.new-info-contentMainList').children('li:eq(0)').height(),null,null];
        let IntervalFn = ()=>{
                lastDom = $('.new-info-contentMainList').children('li').eq(-1);
                $('.new-info-contentMainList').animate({"top": -animateHeight}, 300, () => {
                    lastDom = $('.new-info-contentMainList').children('li').eq(-1);
                    infoTempDom = $('.new-info-contentMainList').children('li').eq(0);
                    animateListIndex++;
                    $('.new-info-contentMainList').children('li').eq(0).remove();
                    // $('.new-info-contentMainList').append(lastDom);
                    $('.new-info-contentMainList').append(infoTempDom);
                    $('.new-info-contentMainList').css('top', 0);//$('.new-info-contentMainList').children('li').eq(-1).remove()
                    (animateListIndex == 1)?null:(animateListIndex == 7?$('.new-info-contentMainList').append(lastDom):null);
                    if(animateListIndex == 7){
                        animateListIndex = 0;
                        //    最后一个结点必须和第一个节点内容一样
                    }
            });
            //等到时后台数据传上来再看看错没错
        };
         infoTime = setInterval(IntervalFn,1500);
        $('.new-info-contentMain').on('mouseenter',()=>{
            clearInterval(infoTime);
        }).on('mouseleave',()=>{
            animateListIndex = 0;
            infoTime = setInterval(IntervalFn,1500);
        });
        /*
            修改箭头指向
         */
        // let arrow = new Set(['↓','→','↑']);
        //  let turnArrow = ()=>{
        //      for(let i = 0;i<$('.new-info-contentMainList'))
        //  };
        //伪代码就是遍历每个li跟之前的值比较里面带类名info_price然后大于就取向上的箭头 小于取向下的箭头 等于就不变
        /*-------------------------------------------------------------------------------*/
        turnColorFn('.new-apply-top-ListMain-content','a');
        turnColorFn('.new-purchase-top-ListMain-content','a');
        turnColorFn('.new-info-contentMainList','a');
        /*--------------------------------------------------------------------------------*/

        // /*三角形移动*/
        // let [LeftDistance,clickLeftDistance,tempLeft]= [$('.first_text').width()/2,null,null];
        // $('.productList-triangle').css({'left':LeftDistance.left});
        // //下面的.productListContent_firstList要写成参数的形式
        // let productListCon_effect = (active_dom)=>{
        //         let ArrayProductList = $(active_dom).find('li.big_icon');
        //         // console.log(ArrayProductList)
        //         $(active_dom).find('li.big_icon').each((index,ele)=>{
        //             $(ele).on('click',()=>{
        //
        //             //这里要写的是动态添加框跟三角形 这里有缺陷就是只能是两行 如果是三行要用循环遍历出来即可
        //             (index < Math.ceil(ArrayProductList.length/2))?((()=>{
        //                 clickLeftDistance = $(ele).position();
        //                 tempLeft = $('.productList-triangle').position().left;
        //                  // console.log(clickLeftDistance);
        //                 // console.log(tempLeft);
        //                 $('.productListContent').find("div.productLine").remove();
        //                 $('.productListContent').find('div.productList-content').remove();
        //                 trendApplyDiv('.productListContent_first');
        //                 $('.productList-triangle').css({'left':tempLeft});
        //                 $('.productList-triangle').stop(true,true).animate({
        //                     'left':clickLeftDistance.left+LeftDistance-21.4
        //                 },500);
        //                 // $('.productList-triangle').css({'left':clickLeftDistance.left});
        //             })()):((()=>{
        //                 clickLeftDistance = $(ele).position();
        //                 tempLeft = $('.productList-triangle').position().left;
        //                 // console.log(clickLeftDistance);
        //                 // console.log(tempLeft);
        //                 $('.productListContent').find("div.productLine").remove()
        //                 $('.productListContent').find('div.productList-content').remove();
        //                 trendApplyDiv('.productListContent_second');
        //                 $('.productList-triangle').css({'left':tempLeft});
        //                 $('.productList-triangle').stop(true,true).animate({
        //                     'left':clickLeftDistance.left-LeftDistance
        //                 },500);
        //             })());
        //             /*下面框淡入淡出*/
        //             $('.contentHot-List').children('li').remove();
        //             // circulateFn(6,'.contentHot-List',newListContentHotChildren);//为了增加数据
        //
        //
        //             $('.contentHot-List').each((index,ele)=>{
        //                 $(ele).fadeOut(100).fadeIn(500);
        //             });
        //         });
        //
        //     });
        // };
        // productListCon_effect('.productListContent');
        /*--------------------------------------------------------------------------------*/

    });
})();

